gdk/broadway/toarray.pl: Fix Code Generation for MSVC
authorChun-wei Fan <fanchunwei@src.gnome.org>
Wed, 22 Oct 2014 12:03:34 +0000 (20:03 +0800)
committerChun-wei Fan <fanchunwei@src.gnome.org>
Thu, 23 Oct 2014 01:12:22 +0000 (09:12 +0800)
The current implementation of this script generate headers with \x-escaped
strings that can become too long (> 65535 characters) for Visual Studio
to consume, hence the build of broadwayd would break on Visual Studio.

This changes the script to instead format the string as an array of hex
characters, not unlike what GResource does, so that builds can continue as
normal on Visual Studio builds as well.

https://bugzilla.gnome.org/show_bug.cgi?id=739001

gdk/broadway/toarray.pl

index b8cdb6fdf6ff361bb84f553c2274683bbcb65c39..ac8b5ff3b76a9a2253e863fa444c3d9962df78b0 100755 (executable)
@@ -1,17 +1,22 @@
 #!/usr/bin/perl -w
 
 my $ARRAYNAME = $ARGV[0];
-print "static const char $ARRAYNAME\[\] = \"";
+my $first = 0;
+print "static const char $ARRAYNAME\[\] = {";
 
 for ($i = 1; $i <= $#ARGV; $i = $i + 1) {
     my $FILENAME = $ARGV[$i];
     open FILE, $FILENAME or die "Cannot open $FILENAME";
     while (my $line = <FILE>) {
         foreach my $c (split //, $line) {
-            printf ("\\x%02x", ord ($c));
+            if ($first == 1) {
+                printf (",\n");
+            }
+            printf ("0x%02x", ord ($c));
+            $first = 1;
         }
     }
 }
 
-print "\";\n";
+print "};\n";